import akshare as ak
import pandas as pd

all_bond_df = pd.read_csv("D:\\InstantPremiumRegression\\raw_data\\akshare_bond_convert_jsl_1106.csv", encoding="GBK")
all_bond_df["clean_stock_id"] = all_bond_df["stock_id"].str.slice(2, 10)
for n, rows in all_bond_df.iterrows():
    bond_id = rows["pre_bond_id"]
    stock_id = rows["stock_id"]
    clean_bond_id = rows["bond_id"]
    clean_stock_id = rows["clean_stock_id"]

    print(rows["pre_bond_id"], rows["stock_id"])

    bond_df = ak.bond_zh_hs_cov_daily(symbol=bond_id)
    bond_df.to_csv(f"D:\\learn_and_test_data\\daily\\{clean_bond_id}.csv")
    stock_df = ak.stock_zh_a_daily(symbol=stock_id)
    stock_df.to_csv(f"D:\\learn_and_test_data\\daily\\{clean_stock_id}.csv")
